package fr.maistre.champagne.fragments;

import fr.maistre.champagne.GameActivity;
import fr.maistre.champagne.R;
import fr.maistre.champagne.model.NiveauDeDifficulté;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

public class CreateGameFragment extends DialogFragment {

	EditText playerName;
	EditText companyName;
	NiveauDeDifficulté niveauDeDifficulté;
	Button buttonStart;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_creategame,
				container, false);
		return rootView;
	}

	@Override
	public void onStart() {
		super.onStart();
		buttonStart = (Button) getView().findViewById(R.id.buttonStart);

		playerName = (EditText) getView().findViewById(R.id.editTextPlayerName);
		companyName = (EditText) getView().findViewById(
				R.id.editTextCompanyName);

		buttonStart.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent game = new Intent(getActivity(), GameActivity.class);
				game.putExtra("NewGame", true);
				game.putExtra("CompanyName", companyName.getText().toString());
				
				game.putExtra("PlayerName", playerName.getText().toString());
				CreateGameFragment.this.dismiss();
				startActivity(game);
				
			}
		});


	}
}
